Skip to content

Vendor crate dependencies in sourcejobs - #1144

Open
Blast545 wants to merge 2 commits into
cottsay/dh-cargofrom
blast545/vendor-cargo-crates
Open

Vendor crate dependencies in sourcejobs#1144
Blast545 wants to merge 2 commits into
cottsay/dh-cargofrom
blast545/vendor-cargo-crates

Conversation

@Blast545

@Blast545 Blast545 commented Jul 20, 2026

Copy link
Copy Markdown

We ship the source code of the dependencies required for a crate using cargo vendor before building it.

We use a per-package flag to enable it / disable it.

Decision: we leave git sources and private registries out of the vendoring, at least for now

@cottsay cottsay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add RPM changes to this PR as well.

It would be a good idea to leverage "Multiple Upstream Tarballs" to keep the vendor crates separate. The unpacking story is pretty clean.

We also need to make this process "opt-in", likely based on a specific configuration in the <export> section of the package.xml file.

Comment thread ros_buildfarm/sourcedeb_job.py Outdated


def build_sourcedeb(sources_dir, os_name=None, os_code_name=None):
def _vendor_cargo_crates(sources_dir):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be refactored into a common location so that the RPM builds can invoke it as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved into cargo.py so that it can be re-used. Also modified the function so that it won't assume debian/vendor, and now instead receives a path, since it might be different for RPM.

Comment thread ros_buildfarm/sourcedeb_job.py Outdated
Comment on lines +121 to +122
cmd = [
'cargo', 'vendor', '--locked', os.path.join('debian', 'vendor')]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we won't be able to use --locked because it would require re-generation of the lock file every time an upstream ROS cargo package version is updated.

Suggested change
cmd = [
'cargo', 'vendor', '--locked', os.path.join('debian', 'vendor')]
cmd = [
'cargo', 'vendor', os.path.join('debian', 'vendor')]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm iterating on that locally. quilt complains if we generate a lockfile and ship it if it wasn't part of the original source, so I'm currently running cargo vendor and later delete the file. commit coming later

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm covering both possibilities in current implementation, not quite sure if the locked path will break, but can be easily removed after testing.

Comment on lines +181 to +184
' --net=host' +
' --net=$docker_network' +

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep existing precedent and still allow network access during these builds, but we should update the cargo configuration to disallow network access as part of the Bloom template.

https://doc.rust-lang.org/cargo/reference/config.html#netoffline

@Blast545 Blast545 Jul 28, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you agree to disable it here for developing and then restore it? I wouldn't like us to hit a specific corner case of cargo ignoring its own --offline flag. (One case, apparently, build scripts and proc macros ignore this flag, as per LLM discussion)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, any reason to keep existing precedent? I thought it was a bug when I found it, and imagined it was a good opportunity to do it differently here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted those changes for now

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Blast545
Blast545 force-pushed the blast545/vendor-cargo-crates branch from 94ab9b1 to 2fc4fc2 Compare August 1, 2026 00:18
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Blast545
Blast545 marked this pull request as ready for review August 1, 2026 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants